<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>
     let obj={
         name:'tom',
         age:'18',
         phone:'12321'
     }
    //  console.log(obj)
    //  {...this.obj}
    //  console.log({money:'100',...obj})

     //对象拷贝
    //  浅拷贝
    //  let newObj=obj

     //深拷贝
    //  方法一：json.stringify
    // let newObj=JSON.parse(JSON.stringify(obj))

    //方法二：递归循环

    //方法三：...展开符
    // let newObj={...obj}

    //方法四: object.assign
    //    对象深拷贝
    //    对象合并
    let newObj=Object.assign({},obj)
    console.log('Object.assign',newObj)

    newObj.name='bob'
    console.log('newObj',newObj.name)
    console.log('obj',obj.name)
    
        
    </script>
</body>
</html>